let ma = new Vue({
    el: '#manage-main',
    data: {
        admin: JSON.parse(sessionStorage.getItem("admin")),
        users:[],
        showFilms:[],
        notShowFilms:[],
        halls:[],
        tickets:[],
        ticketSum:""
    },
    created(){
        // 查询所有用户
        $.get('http://localhost:8080/cinema/api/UserListServlet.do', function (dto) {
            ma.users = dto.value;
        });

        // 查询所有已上映的影片
        $.get('http://localhost:8080/cinema/api/SelectShowsFilmServlet.do', function (dto) {
            ma.showFilms = dto.value;

        });

        // 查询所有未上映的影片
        $.get('http://localhost:8080/cinema/api/SelectNotShowsFilmServlet.do', function (dto) {
            ma.notShowFilms = dto.value;
        });


        // 查询所有影厅
        $.get('http://localhost:8080/cinema/api/HallListServlet.do', function (dto) {
            ma.halls = dto.value;
        });


        // 查询所有影票数
        $.get('http://localhost:8080/cinema/api/TicketListServlet.do', function (dto) {
            ma.tickets = dto.value;
        });

        // 查询票房总额
        $.get('http://localhost:8080/cinema/api/TicketSumServlet.do', function (dto) {
            ma.ticketSum = dto.value;
        });


    }
});



window.onload=function(){

    setInterval(function () {
        //第一：创建对象
        var d = new Date();

        //第二：调用对象的属性和方法
        //1.获取相关时间信息
        var year = d.getFullYear();
        var month = d.getMonth() + 1;
        var day = d.getDate();
        var hours = d.getHours();
        var minutes = d.getMinutes();
        var seconds = d.getSeconds();
        var milliseconds = d.getMilliseconds();

        //2.拼接字符串
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        if (minutes < 10) {
            minutes = "0" + minutes;
        }
        if (seconds < 10) {
            seconds = "0" + seconds;
        }

        //3.显示在h1节点中
        var aaa = document.getElementById("showTime");
        aaa.innerText = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds; //+ " . " + milliseconds;
    }, 1);

}